import 'package:flutter/material.dart';

class GridViewCase extends StatefulWidget {

  const GridViewCase({super.key});

  @override
  _GridViewCase createState() => _GridViewCase();
}

class _GridViewCase extends State<GridViewCase> {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(10),
       child: GridView.extent(
         maxCrossAxisExtent: 400, // 主轴上元素的宽度
          mainAxisSpacing: 10, // 主轴间距
          crossAxisSpacing: 10, // 交叉轴间距
          childAspectRatio: 1, // 元素宽高比,
        children: [
          Container(
            color: Colors.blue,
            alignment: Alignment.center,
            child: const Text("今天好开心", style: TextStyle(color: Colors.white)),
          ),
           Container(
            color: Colors.blueGrey,
            alignment: Alignment.center,
            child: const Text("今天好开心", style: TextStyle(color: Colors.white)),
          ), Container(
            color: Colors.red,
            alignment: Alignment.center,
            child: const Text("今天好开心", style: TextStyle(color: Colors.white)),
          ),
           Container(
            color: Colors.green,
            alignment: Alignment.center,
            child: const Text("今天好开心", style: TextStyle(color: Colors.white)),
          ), Container(
            color: Colors.deepOrangeAccent,
            alignment: Alignment.center,
            child: const Text("今天好开心", style: TextStyle(color: Colors.white)),
          ),
           Container(
            color: Colors.deepPurple,
            alignment: Alignment.center,
            child: const Text("今天好开心", style: TextStyle(color: Colors.white)),
          )
        ],
       ),
    );
  }
}